package ReverseWords;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class ReverseWords {

	/**
	 * @param args
	 * @throws FileNotFoundException
	 */
	public static void main(String[] args) throws FileNotFoundException {
		String file = "src/ReverseWords/B-large-practice.in";
		Scanner sc = new Scanner(new File(file));

		int numberOfsets;
		numberOfsets = sc.nextInt();
		sc.nextLine();

		for (int i = 1; i <= numberOfsets; i++) {
			String[] pars = sc.nextLine().split(" ");

			System.out.print("Case #" + i + ":");
			for (int j = pars.length - 1; j >= 0; j--) {
				// Reverse Order
				System.out.print(" " + pars[j]);
			}
			System.out.println();
		}
		sc.close();
	}
}
